package bg.btanev.eightyfour.domain.person;

import org.apache.commons.lang.Validate;

import bg.btanev.eightyfour.domain.entitybase.DomainValue;

/**
 * @author B.Tanev
 *
 */
public class ContactInfo implements DomainValue {
	/**
	 *
	 */
	private static final long serialVersionUID = 4266636372772601368L;

	private String email; // unique; not null
	private String telephone;
	private String webSite;
	private Address address;

	protected ContactInfo() {
		super();
	}

	public ContactInfo(String email, String telephone, Address address, String webSite) {
		this();
		Validate.notEmpty(email, "Contact information email cannot be empty.");

		this.email = email;
		this.telephone = telephone;
		this.address = address;
		this.webSite = webSite;
	}

	public String getEmail() {
		return email;
	}

	public String getTelephone() {
		return telephone;
	}

	public Address getAddress() {
		return address;
	}

	public String getWebSite() {
		return webSite;
	}

	@Override
	public String toString() {
		return "ContactInfo [address=" + address + ", email=" + email + ", telephone=" + telephone + ", webSite="
				+ webSite + ", toString()=" + super.toString() + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((email == null) ? 0 : email.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ContactInfo other = (ContactInfo) obj;
		if (email == null) {
			if (other.email != null)
				return false;
		} else if (!email.equals(other.email))
			return false;
		return true;
	}
}
